; Installer for dCN!mULTiTOP
; (C) 1996 by TranceTip (dCN-/FdEZiGN)

; $VER: Install dCN!mULTiTOP 1.0 (7.7.96)
; Requires at least Installer 43.x (included)

(set #appname "dCN!mULTiTOP")
(set #destdir "FAME:Doors")
(set #syscmddestdir "FAME:Settings/Doors/SYSCMD")
(set #bbscmddestdir "FAME:Settings/Doors/BBSCMD")
(set #sourcedir "Data")

(set @default-dest #destdir)
(set @app-name #appname)

(if (= @language "deutsch")
  (
  (set #welcometext (cat "Willkommen zum Installationsprogramm von " #appname ".\n\n" #appname " ist ein Paket aus insgesamt drei Multi-Top Utilities fr FAME."))
  (set #willbecopied (cat "Das " #appname "-Programmpaket wird nun nach \"" #destdir "\" installiert. Die bentigten Verzeichnisse werden dort erstellt."))
  (set #oldrenamed (cat "\n\nDie dort bereits existierenden Versionen der Teilprogramme von " #appname " werden vorher umbenannt."))
  (set #designs (cat #appname " bietet schon jetzt eine Auswahl von insgesamt %ld unterschiedlichen, chicen Designs!\n\nBitte lesen Sie den Guide und denken Sie daran, da " #appname " Shareware ist. Schne selbstgemachte Designs sollten an den Autor gesendet werden.\n\nDie registrierte Version bietet brigens eine Reihe zustzlich Features!\n\n\nSigning off,\n\nTranceTip (dCN-/FdEZiGN)"))
  (set #installingfiles "Installiere bentigte Dateien...")
  (set #installsyscmds "Jetzt werden drei SYSCMDs erstellt. Falls diese im System schon existieren, wird gefragt, ob darber installiert werden soll.\n\nFalls nicht, wird z.B. aus \"ULSTAT\" automatisch \"ULSTAT(1,2,3...)\" etc. gemacht.")
  (set #syscmdexists "Das SYSCMD \"%s\" existiert bereits.\n\nWollen Sie es trotzdem berschreiben oder es mit \"%s\" versuchen?")
  (set #overwrite "berschreiben")
  (set #next "Nchstes")
  (set #writesyscmd "Schreibe nun das SYSCMD \"%s\".")
  (set #installbbscmds "Nun werden zwei BBSCMDs erstellt (\"Weektop\" und \"Conftop\").\n\nHierbei wird keine berprfung durchgefhrt.")
  )

  (
  (set #welcometext (cat "Welcome to the installation script for " #appname ".\n\n" #appname " is a packet of three multitop tools for FAME."))
  (set #willbecopied (cat #appname " will now be installed to \"" #destdir "\". The required directories will be created there."))
  (set #oldrenamed (cat "\n\nThe already existing versions of the program parts of " #appname " will be renamed before."))
  (set #designs (cat #appname " already features a selection of %ld different lovely designs!\n\nPlease read the guide and remember that " #appname " is Shareware. Nice selfmade designs should be sent to the author.\n\nThe registered version has some additional features, by the way.\n\n\nSigning off,\n\nTranceTip (dCN-/FdEZiGN)"))
  (set #installingfiles "Installing required files...")
  (set #installsyscmds "Now three SYSCMDs will be created. If they already exist in your FAME system, you will be asked if they should be overwritten.\n\nIf not, e.g. \"ULSTAT\" will be automatically converted to \"ULSTAT(1,2,3...)\" etc.")
  (set #syscmdexists "The SYSCMD \"%s\" already exists.\n\nWould you like to overwrite it or would you like to try installing it as \"%s\"?")
  (set #overwrite "Overwrite")
  (set #next "Next")
  (set #writesyscmd "Now writing SYSCMD \"%s\".")
  (set #installbbscmds "Now two BBSCMDs will be created (\"Weektop\" and \"Conftop\").\n\nAny already existing of these two will be overwritten.")
  )
)

(welcome #welcometext)
(complete 0)

(if (exists (tackon #destdir "dCN!tOP"))
  (
    (message (cat #willbecopied #oldrenamed))
    (delete (tackon #destdir "dCN!tOP.old" (all)))
    (rename (tackon #destdir "dCN!tOP") (tackon #destdir "dCN!tOP.old"))
  )

  (message #willbecopied)
)

(if (exists (tackon #destdir "dCN!CONFTOP"))
  (
    (delete (tackon #destdir "dCN!cONFTOP.old" (all)))
    (rename (tackon #destdir "dCN!cONFTOP") (tackon #destdir "dCN!cONFTOP.old"))
  )
)

(if (exists (tackon #destdir "dCN!wEEKTOP"))
  (
    (delete (tackon #destdir "dCN!wEEKTOP.old" (all)))
    (rename (tackon #destdir "dCN!wEEKTOP") (tackon #destdir "dCN!wEEKTOP.old"))
  )
)

(complete 20)

(working #installingfiles)

(copyfiles
  (source #sourcedir)
  (dest #destdir)
  (all)
  (nogauge)
  (optional force)
)

(complete 60)

(message #installsyscmds)


(foreach "Doorsettings/SYSCMD" "#?"
  (
    (set #num 0)
    (set #finished 0)
    (set #filename (tackon #syscmddestdir @each-name))
    (set #file #filename)
    (while (and (not #finished) (exists #file))
      (
        (if (askbool (default 0) (prompt (#syscmdexists (fileonly #file) (cat (fileonly #filename) (+ #num 1)))) (choices #overwrite #next) (help @askbool-help))
          (
            (set #finished 1)
          )

          (
            (set #num (+ #num 1))
            (set #file (cat #filename #num))        
          )
        )
      )
    )
   
    (message (#writesyscmd (fileonly #file)))

    (copyfiles
      (source (tackon "Doorsettings/SYSCMD" @each-name))
      (dest (pathonly #file))
      (newname (fileonly #file))
      (all)
      (nogauge)
      (optional force)
    )
  )
)

(complete 80)

(message #installbbscmds)
(copyfiles
  (source "DoorSettings/BBSCMD")
  (dest #bbscmddestdir)
  (all)
  (nogauge)
  (optional force)
)

(copyfiles
  (source "")
  (dest (tackon #destdir "dCN!tOP"))
  (pattern "#?.guide#?")
  (nogauge)
  (optional force)
)

(set a 0)
(foreach "Data/dCN!tOP/Designs" "#?"
  (set a (+ a 1))
)

(foreach "Data/dCN!wEEKTOP/Designs" "#?"
  (set a (+ a 1))
)

(foreach "Data/dCN!cONFTOP/Designs" "#?"
  (set a (+ a 1))
)

(complete 100)

(message (#designs a))
